#!/usr/bin/env python
# --*-- conding:utf-8 --*--
# @Time : 2024/1/26
# @Author : liangpp
# @Email : mobaicloud@163.com
# @Software : PyCharm


from carlargescreen.utils.get_alldata import get_alldata


def get_centerleft():
    allcars = list(get_alldata())
    brand_car = {}
    for c in allcars:
        if brand_car.get(c.brand_name, None) == None:
            brand_car[c.brand_name] = int(c.count)
        else:
            brand_car[c.brand_name] += int(c.count)
    sort_list = sorted(brand_car.items(), key=lambda d: d[1], reverse=True)[:10]
    leftseries_list = []
    leftxdata_list = []
    for tup in sort_list:
        leftxdata_list.append(tup[0])
        last_dict = {}
        last_dict["value"] = tup[1]
        last_dict["name"] = tup[0]

        leftseries_list.append(last_dict)
    # print(leftxdata_list)
    # print(leftseries_list)
    return leftxdata_list, leftseries_list
